package stores

import (
	"lesson01/instructions/base"
	"lesson01/rtda"
)

type ILoad struct {
	base.Index8Instruction
}

func (e *ILoad) Execute(frame *rtda.Frame) {
	_iload(frame, uint(e.Index))
}

type ILoad_0 struct {
	base.NoOperandsInstruction
}

func (e *ILoad_0) Execute(frame *rtda.Frame) {
	_iload(frame, 0)
}

type ILoad_1 struct {
	base.NoOperandsInstruction
}

func (e *ILoad_1) Execute(frame *rtda.Frame) {
	_iload(frame, 1)
}

type ILoad_2 struct {
	base.NoOperandsInstruction
}

func (e *ILoad_2) Execute(frame *rtda.Frame) {
	_iload(frame, 2)
}

type ILoad_3 struct {
	base.NoOperandsInstruction
}

func (e *ILoad_3) Execute(frame *rtda.Frame) {
	_iload(frame, 3)
}

func _iload(frame *rtda.Frame, index uint) {
	val := frame.LocalVars().GetInt(index)
	frame.OperandStack().PushInt(val)
}
